<?php
class Api_MixturasController extends App_Controller {
	private $_model;
    
    public function init() {
        parent::init();
        
        // Load model
        $this->_model = new Api_Model_Mixturas();
    }
    
    public function indexAction () {
        echo json_encode($this->_model->getMixturas());
	}

	public function postAction() {
		$mixtura = json_decode($this->_request->getRawBody(), true);
        if (!$this->_model->addMixtura($mixtura)) {
            $this->_response->setHttpResponseCode(500); 
        }
	}

	public function putAction() {
		$mixtura = json_decode($this->_request->getRawBody(), true);
		if (!$this->_model->editMixtura($mixtura)) {
            $this->_response->setHttpResponseCode(500); 
        }
	}

	public function getAction() {
		$id = $this->_request->getParam('id');
        echo json_encode($this->_model->getMixtura($id));
	}
}
